<?php

namespace app\admin\controller;

use app\admin\service\Curlear;
use app\admin\service\LoginService;
use app\common\controller\Base;
use app\admin\validate\LoginRequest;
use Mpdf\Mpdf;
use think\App;
use think\Exception;
use think\Request;

/**
 * Class Orea
 * @package app\admin\controller
 * 试验品哈哈
 */
class Orea extends Base
{

    /**
     * @return string
     * @throws \Mpdf\MpdfException
     */
    public function inoo()
    {
        set_time_limit(0);
        $html = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>委托办理商标事务合同45646546</title>
<style>
body{ font-family: 'Microsoft Yahei'; font-size: 14px; }
.mode-wrap{ width: 595px; margin: 0 auto; }
.mode-wrap table{ width: 595px; }
table.head{ height: 80px; }
.head .logo{ display: inline-block; width: 285px; }
.head .tit{ display: inline-block; width: 297px; height: 50px; line-height: 50px; font-size: 14px; color: #666; text-align: right; }
.text-center{ text-align: center; }
.text-left{ text-align: left; }
.applyer-name{ line-height: 30px; font-size: 16px; }
.analysis table { border-collapse:collapse; width:595px; margin: 0 auto; table-layout:fixed; word-wrap:break-word; word-break:break-all;
}
.analysis table, .analysis table td { border: 1px solid #999; }
.analysis table td{ padding: 16px 10px; line-height: 26px; word-wrap:break-word; word-break:break-all; }
.analysis table td:last-child{ text-align: left; }
.foot{ margin-top: 30px; color: #666; word-wrap:break-word; word-break:break-all; }
.foot p{
  line-height: 24px;
  padding: 0;
  margin: 0;
}
</style>
</head>
<body>
  <div class=\"mode-wrap\">
    <table cellpadding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"head text-center\" style=\"width: 595px;\">
      <tr>
        <td class=\"text-left\" style=\"width: 285px;\">
          <div class=\"logo\">
            <img src=\"http://32.zhixie.com/_nuxt/img/e6543e6.png\" width=\"170\" height=\"50\">
          </div>
        </td>
        <td style=\" width: 297px; vertical-align: bottom;\"><div class=\"tit\">知协 - 32.CN</div></td>
      </tr>
    </table>
    <h1 class=\"text-center\">商标检索分析报告</h1>
    <p class=\"applyer-name text-center\">申请人：132</p>
    <div class=\"content\">
      <div class=\"analysis\">
        <table cellpadding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"text-center\" style=\"width: 595px;\">
          <tbody>
            <tr>
              <td style=\"width: 120px\">商标名</td>
              <td style=\"width: 432px;\">798</td>
            </tr>
            <tr>
              <td>涉及类别</td>
              <td class=\"text-left\">465</td>
            </tr>
            <tr>
              <td>分析及结论</td>
              <td class=\"text-left\">132</td>
            </tr>
            <tr>
              <td>建议</td>
              <td class=\"text-left\">456</td>
            </tr>
            <tr>
              <td width=\"120\">检索结果</td>
              <td class=\"text-left\">789</td>
            </tr>
            <tr>
              <td>相同商标</td>
              <td class=\"text-left\">465</td>
            </tr>
            <tr>
              <td>相似商标</td>
              <td class=\"text-left\">123</td>
            </tr>
            <tr>
              <td colspan=\"2\" class=\"text-left\" style=\"width: 552px;\">
                <div style=\" height: 82px; word-wrap:break-word; word-break:break-all;\">
                  注：因商标检索系统更新的滞后性和以相关法律法规规定的风序良俗、政治因素的考量
                  <br> 以及检索人员难以避免的检索疏忽，同时商标审查期间存在的大概三个月盲查期等因素，
                  <br> 本报告仅作为客户参考之用，并非具有绝对性授权前景的权威文件。
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div class=\"foot text-center\">
      <p>浙江贰贰网络有限公司</p>
      <p>浙江省杭州市西湖区紫霞街 1760000 号杭州互联网创新创业园 2 号楼 11 楼</p>
      <p>32.CN</p>
    </div>
  </div>
</body>
</html>
";
        $path = "C:\Users\adminpc\Desktop\wrok\website1.pdf";
        $filename = '\pppdddfff.png';
        $type = 'F';
        $MPdf = new Mpdf([
            'fontdata' => array_merge((new \Mpdf\Config\FontVariables())->getDefaults()['fontdata'], [
                'siyuanheiti' => [
                    'R' => 'siyuanheiti.ttf'
                ]
            ]),
            'default_font' => 'siyuanheiti'
        ]);
        $MPdf->autoScriptToLang = true;
        $MPdf->autoLangToFont = true;
        $MPdf->WriteHTML($html);
//        $MPdf->Output();
        $MPdf->Output($path.$filename, \Mpdf\Output\Destination::FILE);
        return $path.$filename;
//$type='I'；在线预览模式
//$type='D'；下载模式
//$type='f'；生成后保存到服务器
//$type='s'；返回字符串，此模式下$filename会被忽视
    }

    /**
     * @param $html
     * @param string $return
     * @return string
     * @throws \Mpdf\MpdfException
     * html转pdf格式,return:url返回地址，否则直接输出
     */
    public static function htmlToPdf($html, $return = 'url') {

        $MPdf = new Mpdf([
            'fontdata' => array_merge((new \Mpdf\Config\FontVariables())->getDefaults()['fontdata'], [
                'siyuanheiti' => [
                    'R' => 'siyuanheiti.ttf'
                ]
            ]),
            'default_font' => 'siyuanheiti'
        ]);

        $MPdf->WriteHTML($html);

        // 直接输入PDF
        if ($return != 'url') {
            return $MPdf->Output();
        }

        $files = FileService::getPathFile('pdf', 'pdf');

        $MPdf->Output($files['apfile'], \Mpdf\Output\Destination::FILE);

        return $files['path'] . $files['file'];
    }



}